// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
//1.逆序输出：9 2 5 7 8  --> 8 7 5 2 9
int[] arr1 = { 9, 2, 5, 7, 8 };

static void change(int[] arr)
{
    int len = arr.Length;
    int temp;
    for (int i = 0; i < len / 2; i++)
    {
        temp = arr[i];
        arr[i] = arr[len - 1 - i];
        arr[len - 1 - i] = temp;
    }
}

change(arr1);

for (int i = 0; i < arr1.Length; i++)
{
    Console.Write(arr1[i] + " ");
}
Console.WriteLine();


//2. 求最大最小值{1, -1, 5, 6, 8, 101}
int[] arr2 = { 1, -1, 5, 6, 8, 101 };

static int getMin(int[] arr)
{
    int min = arr[0];
    int len = arr.Length;
    for (int i = 0; i < len; i++)
    {
        if (min > arr[i])
        {
            min = arr[i];
        }
    }
    return min;
}

static int getMax(int[] arr)
{
    int max = arr[0];
    int len = arr.Length;
    for (int i = 0; i < len; i++)
    {
        if (max < arr[i])
        {
            max = arr[i];
        }
    }
    return max;
}

Console.WriteLine(getMin(arr2));
Console.WriteLine(getMax(arr2));


//3. a=9 b=5 c=6  --> 5 6 9
int[] arr3 = { 9, 6, 5, 5, 8, 4, 7, 8, 9, 6, 1, 2, 5 };

static void sort(int[] arr)
{
    int temp;
    int len = arr.Length;
    for (int i = 0; i < len; i++)
    {
        for (int j = 0; j < len - i - 1; j++)
        {
            if (arr[j] > arr[j + 1])
            {
                temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }
}

sort(arr3);

for (int i = 0; i < arr3.Length; i++)
{
    Console.Write(arr3[i] + " ");
}